package com.leyou.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.leyou.dto.SkuDTO;
import com.leyou.entity.Sku;
import com.leyou.mapper.SkuMapper;
import com.leyou.service.SkuService;
import com.leyou.service.SpuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements SkuService {
    @Autowired
    public SkuService skuService;
    @Autowired
    public SpuService spuService;

    //todo 根据spuId查询对应的sku的集合
    @Override
    public List<SkuDTO> listSkuBySpuId(Long id) {
        return SkuDTO.convertEntityList(this.query().eq("spu_id",id).list());
    }


    //todo 根据id集合查询SKU集合
    @Override
    public List<SkuDTO> listSkuBySpuIds(List<Long> ids) {
        return SkuDTO.convertEntityList(this.skuService.listByIds(ids));
    }
}
